package com.qqzone.dao.impl;

import com.myssm.basedao.BaseDAO;
import com.qqzone.dao.ReplyDAO;
import com.qqzone.pojo.Reply;
import com.qqzone.pojo.Topic;

import java.security.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * @author Yang
 * @creat 19:03 2022/8/26
 * @sice 1.8
 */

public class ReplyDAOImpl extends BaseDAO<Reply> implements ReplyDAO {
    @Override
    public List<Reply> getReplyList(Topic topic) {
        return super.executeQuery("select * from t_reply where topic = ?", topic.getId());
    }

    @Override
    public void addReply(Reply reply) {
        executeUpdate("insert into t_reply set content = ? , replyDate = ? , author = ? , topic = ? ",reply.getContent(),reply.getReplyDate(),reply.getAuthor().getId() , reply.getTopic().getId()) ;
    }

    @Override
    public void delReply(Integer id) {
        String sql = "delete from t_reply where id = ?";
        executeUpdate(sql, id);
    }

    @Override
    public Reply getReplyByReplyId(Integer ReplyId) {
        String sql = "select * from t_reply where id = ?";
        return super.load(sql, ReplyId);
    }
}
